cmake_minimum_required(VERSION 3.19)
project(web)

# 设置 C++ 标准为 11
set(CMAKE_CXX_STANDARD 11)

# 设置 UTF-8 编译选项
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")


# 把当前目录添加到包含目录列表
include_directories(${CMAKE_CURRENT_SOURCE_DIR} 
                    ${CMAKE_CURRENT_SOURCE_DIR}/mapper/src/common
                    ${CMAKE_CURRENT_SOURCE_DIR}/mapper/src/entity
                    ${CMAKE_CURRENT_SOURCE_DIR}/mapper/src/sql
                    ${CMAKE_CURRENT_SOURCE_DIR}/mapper/src/util
                    ${CMAKE_CURRENT_SOURCE_DIR}/mapper/src/guard
                    ${CMAKE_CURRENT_SOURCE_DIR}/mapper/src/aop
                    ${CMAKE_CURRENT_SOURCE_DIR}/mapper/src/builder
                    ${CMAKE_CURRENT_SOURCE_DIR}/mapper/src
                    /usr/include/mysql
                    /usr/local/include/hiredis
                    )
#添加库文件搜索路径
link_directories(/usr/lib64/mysql)

# 递归搜索所有源文件
file(GLOB_RECURSE SOURCES 
    "app/*.cpp"
    "frame/*.cpp"
    "fs/*.cpp"
    "json/*.cpp"
    "reflect/*.cpp"
    "socket/*.cpp"
    "task/*.cpp"
    "thread/*.cpp"
    "utility/*.cpp"
    "web/*.cpp"
)

# 设置可执行文件的输出路径为 CMakeLists.txt 所在的目录
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})


# 创建 main 的可执行文件
add_executable(main ${SOURCES} main.cpp)

# 链接 pthread 库和 mapper 库
target_link_libraries(main PRIVATE pthread libmysqlclient.so ssl crypto hiredis)


